﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AsyncPersistence.Services;

namespace AsyncPersistence.Common
{
    public class PersistenceTaskComparer : IEqualityComparer<APersistenceTask>
    {
        // Products are equal if their names and product numbers are equal.
        public bool Equals(APersistenceTask x, APersistenceTask y)
        {
            //Check whether the compared objects reference the same data.
            if (ReferenceEquals(x, y)) return true;

            //Check whether any of the compared objects is null.
            if (ReferenceEquals(x, null) || ReferenceEquals(y, null))
                return false;

            //Check whether the products' properties are equal.
            return x.EntityId() == y.EntityId();
        }

        public int GetHashCode(APersistenceTask persistenceTask) { return (int)persistenceTask.EntityId(); }

    }
}
